#include <bits/stdc++.h>
using namespace std;

const int N= 1e5+5;

int n,m,L,V;//NOfc NOftest
int d[N],v[N],a[N],p[N];
//int pn[N];
int ans1,ans2;
bool s[N]={0};
inline bool isSub(int i,int j){return !(s[i]||s[j]);}

vector<int> G[m];
bool cmp(vector<int>& a,vector<int>& b){
    //if a belong to b ->s[a]=1
    //b belong to a -> s[b]=1
    //a==b -> s[b]=1
    //public:ans2--
    bool tag1=0,tag2=0;
    for(int val1:G[i]){
        int t=0;
        if(!tag1)
        for(int val2:G[j]){
            if(val1==val2) t++;
        }
        if(t==0) tag1=1;//j bt i
    }
    for(int val1:G[j]){
        int t=0;
        if(!tag2)
        for(int val2:G[i]){
            if(val1==val2) t++;
        }
        if(t==0) tag2=1;//i bt j
    }
    if(tag1&&tag2) return 0;
    else if(tag1) s[j]=1,ans2--;
    else if(tag2) s[i]=1,ans2--;

    return 0;
}
//start dis  v  a


//vector<pair<int,pair<int,int>>> idx;
inline bool inRange(int i,int k){
    if(k==1) return d[i]<=p[m];
    if(k==2){
        float t=-(float(v[i]-3))/a[i];
        float s=(v[i]+3)*t/2;
        //if(s>L-d[i]) return 0;
        int l=d[i],r=d[i]+s,ret=0;
        for(int t=1;t<=m;t++)
            if(l<=p[t]&&r>=p[t])
            {ret=1;G[t].push_back(i);}
        //if(ret) ;//idx.push_back({i,{l,r});
        return ret;
    }
}


inline void f(){
    for(int i=1;i<=n;i++){
        //d v a
        if(a[i]>=0&&v[i]>V&&inRange(i,1))
            ans1++;//,idx.push_back({i,{d[i],L}});
        else if(a[i]<0&&v[i]>V&&inRange(i,2))
            ans1++;
        else if(a[i]>0&&v[i]<=V){
            float dv=V-v[i];//ds=L-d[i];
            float t=dv/a[i];
            int l=d[i],r=d[i]+(vi+V)*t/2,q=0;
            if(r<=L){
                for(int t=1;t<=m;t++){
                    if(l<=p[t]&&r>=p[t])
                        q=1,G[t].push_back(i);//,
                        //idx.push_back({i,{l,r}});
                }
                if(q) ans1++;
            }
        }
    }
    ans2=m;
    for(int i=1;i<=m;i++){
        for(int j=i+1;j<=m;j++){
            if(isSub(i,j)==0)
            cmp(G[i],G[j]);
        }
    }

    /*for(auto i:idx){
        int d=i.first,
            l=i.second.first,
            r=i.second.second;
        for(int t=1;t<=m;t++){

        }
    }*/
    return;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T-->0){
            ans1=ans2=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++)
            cin>>p[i];
       // idx.resize(0);
        f();
        cout<<ans1<<' '<<ans2<<'\n';
    }
    cout<<flush;
    return 0;
}
